#include "HashTable.h"


template<class K, class V, class Hash = HashFunc<K>>
class unordered_map
{
    struct MapKeyOfT
    {
        const K& operator()(const pair<K, V>& kv)
        {
            return kv.first;
        }
    };
public:

    typedef typename HashTable<K, pair<const K, V>, MapKeyOfT, Hash>::Iterator iterator;

    iterator begin()
    {
        return _ht.Begin();
    }

    iterator end()
    {
        return _ht.End();
    }

    V& operator[](const K& key)
    {
        pair<iterator, bool> ret = insert({ key, V() });
        return ret.first->second;
    }

    pair<iterator, bool> insert(const pair<K, V>& kv)
    {
        return _ht.Insert(kv);
    }

    iterator Find(const K& key)
    {
        return _ht.Find(key);
    }

    bool Erase(const K& key)
    {
        return _ht.Erase(key);
    }

private:
    HashTable<K, pair<const K, V>, MapKeyOfT, Hash> _ht;
};